package com.caishi.lkx.exam.records.dto;

import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSON;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Getter;
import lombok.Setter;

/**
 * 统计记录
 * {
 * 做题数量,
 * 错题数量，
 * 收藏数量
 * }
 */
@Getter
@Setter
public class RecordsCountRecordDto implements OssDto<RecordsCountRecordDto> {
    /**
     * 做题数量
     */
    @Schema(title = "做题数量")
    private int dc;

    /**
     * 错题数量
     */
    @Schema(title = "错题数量")
    private int ec;

    /**
     * 收藏数量
     */
    @Schema(title = "收藏数量")
    private int cc;

    public boolean empty() {
        return dc + ec + cc == 0;
    }

    @Override
    public RecordsCountRecordDto parse(String json) {
        if (StrUtil.isBlank(json)) return this;
        RecordsCountRecordDto d = JSON.parseObject(json, RecordsCountRecordDto.class);
        BeanUtil.copyProperties(d, this);
        return this;
    }
}
